<template>
  <!-- 登录页面 -->
  <div class="login">
    <div class="login-top">
      <p>账号登录</p>
    </div>
    <div class="login-info">
      <div class="user-name">
        <input
          v-model.trim="code"
          type="text"
          name=""
          id=""
          placeholder="用户名/邮箱/手机号"
        />
      </div>
      <div class="user-psw">
        <input
          v-model.trim="password"
          type="password"
          name=""
          id=""
          placeholder="密码"
        />
      </div>
    </div>
    <div class="login-bnt" @click="submit">
      <p>登录</p>
    </div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  data() {
    return {
      code: "",
      password: "",
    };
  },
  methods: {
    ...mapMutations("m_user", ["getToken"]),

    submit() {
      if (!this.code) {
        this.$toast({ message: "请输入账号", position: "bottom" });
      }
      if (!this.password) {
        this.$toast({ message: "请输入密码", position: "bottom" });
      }
      if (!this.code && !this.password) {
        this.$toast({ message: "请输入账号或密码", position: "bottom" });
      }
      if (this.code === "123456" && this.password === "123456") {
        this.$toast({ message: "登录成功", position: "bottom" });
        this.getToken("token");

        if (this.$route.query.goodSdetails) {
          console.log("aa");
          this.$router.go(-1);
        } else {
          this.$router.push("/my");
        }
      } else {
        this.$toast({ message: "账号或密码错误", position: "bottom" });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
// 登录页面样式
.login {
  .login-top {
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-bottom: 1px solid #e5e5e5;
  }
  .login-info {
    height: 100px;
    margin-top: 50px;
    padding: 0 25px;

    input {
      border: 0;
    }

    input::-webkit-input-placeholder {
      color: #cccccc;
      font-size: 18px;
      font-weight: 500;
    }

    .user-name,
    .user-psw {
      padding: 10px 10px;
      border-bottom: 2px solid #e5e5e5;
    }

    .user-name {
    }

    .user-psw {
    }
  }

  .login-bnt {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 16px;
    color: #fff;
    margin: 10px 25px;
    background-color: #ff5777;
    border-radius: 20px;
  }
}
</style>